import { message } from 'antd';
import { initGlobalState, MicroAppStateActions } from 'qiankun';

// 初始化 state
const actions: MicroAppStateActions = initGlobalState({
    from:'',
    message:'hello I am main app',
    state:{},
});

/*
actions.onGlobalStateChange((state, prev) => {
    // state: 变更后的状态; prev 变更前的状态
    // console.log(state, prev);
    if(state.from === 'subapp'){
        message.info(state.message);
    }
});

actions.setGlobalState(state);
actions.offGlobalStateChange();
*/

export default actions;
